<template>
    <div style="width:400px">
        <el-form ref="ruleForm" :model="ruleForm"  label-width="100px"   class="demo-ruleForm">
        <el-form-item label="部门名称" prop="DeptName">
    <el-input v-model="ruleForm.DeptName"></el-input>
  </el-form-item>
  <el-form-item label="描述" prop="Remark">
    <el-input v-model="ruleForm.Remark"></el-input>
  </el-form-item>
 
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')" icon="el-icon-s-promotion">立即修改</el-button>
<el-button @click="resetForm('ruleForm')" icon="el-icon-refresh-left">重置</el-button>
</el-form-item>
</el-form>
</div>
</template>

<script>
export default {
name:'update',
data(){
    return {
      
        ruleForm:{
            DeptID:0,
            DeptName:'',
             Remark:'',
             Type:1,
             LastTime:''
           

        }
       
    }
},
props:['dialogUpdate','data']
,
methods:{
    submitForm(formName) {
        //先验证表单数据
        this.$refs[formName].validate((valid) => {
            if (valid) {
              console.log(this.ruleForm)
           this.axios({
            method:'put',
            url:'Dept',
            data:this.ruleForm
        }).then(res=>{
            if(res.code>0){
              this.$emit('update:dialogUpdate',false)
              this.$emit("gx");
                this.$message({ type:'success', message:res.msg})

            }else{
                this.$message({ type:'danger', message:res.msg})
            }
        })
         
            } else {
                console.log('error submit!!');
                return false;
            }
        });
    },
    resetForm(formName) {
        this.$refs[formName].resetFields();
    }

},
watch:{
 dialogUpdate(newvalue,oldvalue){
    this.ruleForm=this.data;
    }

},created(){
    this.ruleForm=this.data;
}
}
</script>

<style scoped>
</style>